package com.example.springboot2.xdkt.annotation;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class MyCustomConstrainValidator implements ConstraintValidator<MyCustraint, String > {
    @Override
    public void initialize(MyCustraint constraintAnnotation) {

    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if(!(value.equalsIgnoreCase("北京")||(value.equalsIgnoreCase("上海")))){
            return false;
        }
        return true;
    }
}
